<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="tableData">
      <el-table-column label="Ip" prop="operIp" />
      <el-table-column label="用户" prop="operName" />
      <el-table-column label="请求时间" prop="operTime" />
      <el-table-column label="请求链接" prop="operUrl" />
      <el-table-column label="请求方式" prop="method" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getList } from "@/api/sys/operlog";

export default {
  data() {
    return {
      loading: true,
      tableData: [],
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      getList(this.queryParams).then(({ data }) => {
        this.tableData = data.records;
        this.total = data.total;
        this.loading = false;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery() {
      this.dateRange = [];
      this.dateRange1 = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
